package com.banach.prema.executor;

import com.banach.prema.dto.query.AlarmPageQuery;
import com.banach.prema.dto.query.MyAlarmPageQuery;
import com.banach.prema.dto.query.SosPageQuery;
import com.banach.prema.dto.vo.AlarmVO;
import com.banach.prema.dto.vo.SosVO;
import com.banach.prema.repository.AlarmRepository;
import com.ego.framework.core.context.UserHolder;
import com.ego.framework.core.tookit.BeanToolkit;
import com.ego.framework.dto.Response;
import com.ego.framework.model.CustomizePage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ajun
 *
 */
@RestController
public class AlarmQueryExe {

	@Resource
	private AlarmRepository alarmRepository;

	public Response<CustomizePage<AlarmVO>> selectPage(AlarmPageQuery pageQuery){
		return Response.of(alarmRepository.selectPage(pageQuery));
	}

	public Response<CustomizePage<AlarmVO>> selectMyPage(MyAlarmPageQuery myAlarmPageQuery){
		AlarmPageQuery pageQuery = BeanToolkit.getInstance().copy(myAlarmPageQuery, AlarmPageQuery.class);
		pageQuery.setUserId(UserHolder.getLoginUser().getId());
		return Response.of(alarmRepository.selectPage(pageQuery));
	}
}
